﻿Imports YAF.Classes
Imports YAF.Classes.Data
Imports YAF.Core
Imports YAF.Core.Services
Imports YAF.Types
Imports YAF.Types.Constants
Imports YAF.Types.EventProxies
Imports YAF.Types.Interfaces
Imports YAF.Utilities
Imports YAF.Utils
Imports YAF.Utils.Helpers
Imports YAF.Pages
Imports System.IO
Imports System.Data
Public Class Login
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label4.Text = YafContext.Current.CurrentUserData.UserName
        Label5.Text = YafContext.Current.CurrentUserData.RankName
        Label9.Text = YafContext.Current.IsHostAdmin
        Label6.Text = YafContext.Current.IsAdmin
        Label7.Text = YafContext.Current.IsGuest
        Label8.Text = YafContext.Current.IsModeratorInAnyForum


    End Sub

    Public Function SetUserCookie(UserName As String, Password As String) As Boolean

        Dim Check As Boolean = YafContext.Current.Get(Of MembershipProvider)().ValidateUser(UserName, Password)

        If Check = True Then
            FormsAuthentication.SetAuthCookie(UserName, True)

            Return True


        Else
            Return False
        End If


    End Function
    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If SetUserCookie(Textbox1.Text, Textbox2.Text) = True Then
            Label1.Text = ""
            Response.Redirect("/Download.aspx", True)

        Else
            Label1.Text = "Login Failed for " & Textbox1.Text

        End If
    End Sub
    Protected Sub signout()

        FormsAuthentication.SignOut()
        Response.Redirect(Request.Url.ToString, True)
    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        signout()
    End Sub
End Class